import { http } from '@/utils/http'

export interface ExpertiseItem {
  collection_num: number
  content: string
  endtime: string
  frontImg: string
  id: number
  look_num: number
  time: string
  title: string
}

export interface ExpertiseParams {
  deptIds?: string
  deptFlag?: number
  page?: number
  limit?: number
}

export interface ExpertiseData {
  totalCount: number
  items: ExpertiseItem[]
}

/* 知识列表 */
export function getExpertiseList({
  deptIds,
  deptFlag,
  page = 1,
  limit = 10,
}: ExpertiseParams = {}): Promise<IResData<ExpertiseData>> {
  return http.get<ExpertiseData>('/api/MP/GetExpertiseList', {
    deptIds,
    deptFlag,
    page,
    limit,
  })
}

export interface ExpertiseDetail {
  collection_num: number
  content: string
  createtime: string
  frontImg: string
  id: number
  isPublic: number
  ispublish: number
  openClasses: string
  openDepts: string
  openPosts: string
  overtime: string
  publishtime: string
  queryDepts: string
  roleTags: string
  status: number
  title: string
  updatetime: string
  userid: number
  isCollection: boolean
}

/* 知识详情 */
export const getExpertise = (id: number): Promise<IResData<ExpertiseDetail>> => {
  return http.get<ExpertiseDetail>('/api/MP/GetExpertise', {
    id,
  })
}
